/**
 * Group服务类
 * @author yanwl
 * @date 2016-07-13 03:22:15
*/
package com.company.example.service.impl;

import com.company.example.core.common.DaoHelper;
import com.company.example.core.util.AssertUtil;
import com.company.example.model.pojo.Group;
import com.company.example.service.GroupService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("groupService")
public class GroupServiceImpl implements GroupService{
	//声明工作空间
	private final static String nameSpace = "com.company.example.mapper.GroupMapper";

	@Transactional(propagation = Propagation.NESTED)
	@Override
	public boolean insertGroup(Group group) {
		boolean result = DaoHelper.insert(nameSpace, "insertGroup", group);
		AssertUtil.assertTrue(true);
		return result;
	}
	
	@Override
	public boolean deleteGroup(Integer groupId) {
		return DaoHelper.delete(nameSpace, "deleteGroup", groupId);
	}

	@Override
	public boolean updateGroup(Group group) {
		return DaoHelper.update(nameSpace, "updateGroup", group);
	}
	
	@Override
	public Group selectGroupByPrimaryKey(Integer groupId) {
		return (Group)DaoHelper.query(nameSpace, "selectGroupByPrimaryKey", groupId);
	}
	

	@SuppressWarnings("unchecked")
	@Override
	public List<Group> selectAllGroups() {
		return (List<Group>)DaoHelper.list(nameSpace, "selectAllGroups", "");
	}

	@Override
	public int selectGroupTotalRows() {
		return DaoHelper.count(nameSpace, "selectGroupTotalRows", "");
	}
}